<template>
  <div class="text-block" ref="text_block">
    <div class="text-block-header" ref="text_block_header">
      <div class="circle one"></div>
      <div class="circle two"></div>
      <div class="circle three"></div>
    </div>

    <div class="title">
      <span>{{ title }}</span>
    </div>
    <slot>i am default content</slot>
  </div>
</template>

<script setup lang="ts">
import { defineProps, toRefs, withDefaults } from "vue"

const props = withDefaults(
  defineProps<{
    color?: string
    title?: string
  }>(),
  {
    color: "var(--themeColor)",
    title: "title",
  }
)

let { color, title } = toRefs(props)
</script>

<style lang="scss" scoped>
.text-block {
  position: relative;
  width: 100%;
  margin-top: 50px;
  margin-bottom: var(--bottom);
  padding: 14px 20px;
  box-sizing: border-box;
  text-align: justify;
  overflow: unset;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 14px 38px rgb(0 0 0 / 8%), 0 3px 8px rgb(0 0 0 / 6%);
  font-size: 16px;
  transition: all 0.3s var(--n-bezier);
  background: var(--my-text-block-bg);
  &:hover {
    box-shadow: 0 14px 38px rgb(0 0 0 / 14%), 0 3px 8px rgb(0 0 0 / 12%);
  }
  .title {
    display: inline-block;
    position: relative;
    margin-bottom: 10px;
    padding: 0 14px 0 32px;
    height: 32px;
    line-height: 32px;
    border-radius: 0 4px 4px 0;
    background-color: v-bind(color);
    color: #fff;
    transform: translateX(-35px);
    &::after {
      content: "";
      position: absolute;
      top: 100%;
      left: 0;
      width: 0;
      height: 0;
      background-color: transparent;
      border-style: solid;
      border-width: 0 16px 16px 0;
      border-color: transparent;
      border-right-color: v-bind(color);
      filter: brightness(120%);
    }
  }

  .text-block-header {
    width: 100%;
    display: flex;
    align-items: center;
    overflow: hidden;
    border-radius: 4px 4px 0 0;
    height: 30px;
    position: absolute;
    top: -30px;
    left: 0;
    background: var(--my-text-block-header-bg);
    transition: all 0.3s var(--n-bezier);
  }
  .circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-left: 10px;
  }
  .one {
    background: #fc625d;
  }
  .two {
    background: #fdbc40;
  }
  .three {
    background: #35cd4b;
  }
}
</style>
